<html xmlns="http://www.w3.org/1999/xhtml">
<head th:include="commonBase">
<title>导入文件</title>
</head>
<link rel="stylesheet" th:href="@{/common/css/fileIcon.css}"/>
<link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}"/>
<link rel="stylesheet" th:href="@{/plugins/fileinput/css/fileinput.min.css}"/>
<link rel="stylesheet" th:href="@{/common/js/miniui/res/font-awesome/css/font-awesome.min.css}"/>
<link rel="stylesheet" th:href="@{/plugins/fileinput/themes/explorer-fa/theme.css}"/>
<script th:src="@{/plugins/fileinput/js/fileinput.min.js}" type="text/javascript"></script>
<script th:src="@{/plugins/fileinput/js/zh.js}" type="text/javascript"></script>
<script th:src="@{/plugins/fileinput/themes/fa/theme.js}" type="text/javascript"></script>
<script th:src="@{/plugins/fileinput/themes/explorer-fa/theme.js}" type="text/javascript"></script>
<script th:src="@{/bootstrap/js/bootstrap.min.js}" type="text/javascript"></script>
<!-- LayUI -->
<link rel="stylesheet" th:href="@{/plugins/layui/css/layui.css}"/>
<script th:src="@{/plugins/layui/layui.js}" type="text/javascript"></script>
<style type="text/css">
.mini-splitter-border {
	border: 0;
}
</style>
<body>
<div class="mini-fit" >
	<div style="height:100%;width:100%;"><input id="fileId" name="fileId" type="file" multiple="multiple" class="file-loading" ></input></div>
</div>
</body>
<script type="text/javascript">
 /*<![CDATA[*/
 var layer=null;
var element = null;
layui.use(['layer','element'], function(){ //独立版的layer无需执行这一句
	  var $ = layui.jquery, layer = layui.layer;
	   element = layui.element;//独立版的layer无需执行这一句
});
	 //重写mini.alert;
mini.alert= function (message, title,callback) {
	if(callback == undefined){
		return layer.alert(message, {
	    	  title:title,
	    	  closeBtn: 0
	    	  });
	}else{
    return layer.alert(message, {
    	  title:title,
    	  closeBtn: 0
    	  },function(index){
    		  callback();
    		  layer.close(index);
    	  });
	}
}
      function setData(data) {
    		var action = data.action;//获取指令，是新增 还是修改
    		data = mini.clone(data);//获取克隆数据
    	}
 $("#fileId").fileinput({
			 	language : 'zh',
				uploadUrl : basePath + 'uploadCommonFile',
				maxFileCount : 10,//表示允许同时上传的最大文件个数
				maxFileSize:204800,
				minFileCount:1,
				showCaption : true,//是否显示标题
				showPreview:true,
				showUpload:true,
				uploadAsync:true,
				enctype : 'multipart/form-data',//不对发送的字符进行编码
				msgFilesTooLess:'您必须至少选择{n}个文件才能上传，请点击“浏览”选择您需要上传的文件！',
				msgFilesTooMany:'超过了单次上传最大文件数{m}个，请分批次上传！',
				previewFileIcon: '<i class="fa fa-file"></i>',
				browseLabel : "浏览",
				msgSelected:'添加了{n}个文件',
				dropZoneTitle:'拖拽文件到这里 …<br/>最多支持10个文件同时上传<br/>',
			    previewFileIconSettings: {
			        'doc': '<i class="fa fa-file-word-o text-primary"></i>',
			        'xls': '<i class="fa fa-file-excel-o text-success"></i>',
			        'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
			        'jpg': '<i class="fa fa-file-photo-o text-warning"></i>',
			        'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
			        'zip': '<i class="fa fa-file-archive-o text-muted"></i>',
			        'htm': '<i class="fa fa-file-code-o text-info"></i>',
			        'txt': '<i class="fa fa-file-text-o text-info"></i>',
			        'mov': '<i class="fa fa-file-movie-o text-warning"></i>',
			        'mp3': '<i class="fa fa-file-audio-o text-warning"></i>',
			    },
			    previewFileExtSettings: {
			        'doc': function(ext) {
			            return ext.match(/(doc|docx)$/i);
			        },
			        'xls': function(ext) {
			            return ext.match(/(xls|xlsx)$/i);
			        },
			        'ppt': function(ext) {
			            return ext.match(/(ppt|pptx)$/i);
			        },
			        'zip': function(ext) {
			            return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
			        },
			        'htm': function(ext) {
			            return ext.match(/(php|js|css|htm|html)$/i);
			        },
			        'txt': function(ext) {
			            return ext.match(/(txt|ini|md)$/i);
			        },
			        'mov': function(ext) {
			            return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
			        },
			        'mp3': function(ext) {
			            return ext.match(/(mp3|wav)$/i);
			        },
			    },
				textEncoding:"UTF-8"
			}).on('fileuploaded', function(event, data, previewId, index) {
				if(data.response.status == "true"){
					mini.showTips({
			            content:data.response.data ,
			            state: "success",
			            x: "center",
			            y: "center",
			            timeout: 3000
			        });
				}else{
					mini.showTips({
						content:data.response.data ,
			            state: "danger",
			            x: "center",
			            y: "center",
			            timeout: 3000
			        });
				}
			});
	  
 /*]]>*/
</script>
</html>
